"""
用户模块 model
"""


from tortoise import fields, models


class User(models.Model):
    """
    用户数据模型
    """
    id = fields.IntField(pk=True)
    username = fields.CharField(max_length=32, unique=True, description="用户名")
    password = fields.CharField(max_length=64, description="加密后的密码")
    email = fields.CharField(max_length=128, unique=True, description="邮箱")
    phone = fields.CharField(max_length=11, null=True, description="手机号")
    is_active = fields.BooleanField(default=True, description="是否激活")
    is_superuser = fields.BooleanField(default=False, description="是否超级用户")
    created_at = fields.DatetimeField(auto_now_add=True, description="创建时间")
    updated_at = fields.DatetimeField(auto_now=True, description="更新时间")

    class Meta:
        table = "users"
        table_description = "用户表"

    def __str__(self):
        return self.username

